echo 'Output=TAP' >> $@.tmp; \
mv $@.tmp $@)
+%.test: tests/%.js Makefile
+ $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
+ echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \
+ echo 'Type=session' >> $@.tmp; \
+ mv $@.tmp $@)
+
testmetadir = $(datadir)/installed-tests/$(PACKAGE)
testmeta_DATA = $(testfiles:=.test)
+if BUILDOPT_GJS
+insttest_SCRIPTS += tests/test-core.js
+testmeta_DATA += test-core.test
+endif
+
+
endif
])
])
+dnl for tests
+AC_PATH_PROG(GJS, [gjs])
+if test -n "$GJS"; then
+ have_gjs=yes
+else
+ have_gjs=no
+fi
+AM_CONDITIONAL(BUILDOPT_GJS, test x$have_gjs = xyes)
+
AC_CONFIG_FILES([
Makefile
embedded-dependencies/Makefile
libsoup (retrieve remote HTTP repositories): $with_soup
libarchive (parse tar files directly): $with_libarchive
documentation: $enable_gtk_doc
+ gjs-based tests: $have_gjs
dracut: $with_dracut"
AS_IF([test "x$with_dracut" = "xyes"], [
echo " systemd unit dir: $with_systemdsystemunitdir"
--- /dev/null
+#!/usr/bin/env gjs
+
+const Gio = imports.gi.Gio;
+const OSTree = imports.gi.OSTree;
+
+function assertEquals(a, b) {
+ if (a != b)
+ throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
+}
+
+let testDataDir = Gio.File.new_for_path('test-data');
+testDataDir.make_directory(null);
+testDataDir.get_child('some-file').replace_contents("hello world!", null, false, 0, null);
+
+let repoPath = Gio.File.new_for_path('repo');
+let repo = OSTree.Repo.new(repoPath);
+repo.create(OSTree.RepoMode.ARCHIVE_Z2, null);
+
+repo.open(null);
+
+assertEquals(repo.get_mode(), OSTree.RepoMode.ARCHIVE_Z2);
+
+repo.prepare_transaction(null);
+
+let mtree = OSTree.MutableTree.new();
+repo.write_directory_to_mtree(testDataDir, mtree, null, null);
+let [,dirTree] = repo.write_mtree(mtree, null);
+let [,commit] = repo.write_commit(null, 'Some subject', 'Some body', null, dirTree, null);
+print("commit => " + commit);
+
+repo.commit_transaction(null, null);
+
+let [,root,checksum] = repo.read_commit(commit, null);
+let child = root.get_child('some-file');
+let info = child.query_info("standard::name,standard::type,standard::size", 0, null);
+assertEquals(info.get_size(), 12);
+
+print("test-core complete");